<!--
 * @Author: your name
 * @Date: 2022-03-14 15:49:51
 * @LastEditTime: 2022-03-14 18:48:13
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\如何写一个简单的回调函数220314.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>如何写一个简单的回调函数</title>
</head>
<body>
  <script>
    
//函数的参数为回调函数
function fangfang(callback) {
    var data = {
        "name": "fangyalan",
        "age": 18
    };
    callback(data);
}
//调用
fangfang(function (data) {
    //这里操作回调返回的数据
    console.log(data)
})


  </script>
</body>
</html>